.class Lcom/melesta/payment/inapp3/InAppSystem$3;
.super Ljava/lang/Object;
.source "InAppSystem.java"

# interfaces
.implements Lcom/melesta/payment/inapp3/IabHelper$OnIabPurchaseFinishedListener;


# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Lcom/melesta/payment/inapp3/InAppSystem;->buy(Lcom/melesta/payment/inapp3/InAppRequest;)V
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = null
.end annotation


# instance fields
.field final synthetic this$0:Lcom/melesta/payment/inapp3/InAppSystem;

.field final synthetic val$databaseHelper:Lcom/melesta/engine/DatabaseHelper;

.field final synthetic val$mCountPerItem:I

.field final synthetic val$mItemName:Ljava/lang/String;

.field final synthetic val$mSku:Ljava/lang/String;

.field final synthetic val$tr:Lcom/melesta/payment/PaymentTransaction;


# direct methods
.method constructor <init>(Lcom/melesta/payment/inapp3/InAppSystem;Lcom/melesta/engine/DatabaseHelper;Ljava/lang/String;Ljava/lang/String;ILcom/melesta/payment/PaymentTransaction;)V
    .locals 0
    .parameter
    .parameter
    .parameter
    .parameter
    .parameter
    .parameter

    .prologue
    .line 247
    iput-object p1, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->this$0:Lcom/melesta/payment/inapp3/InAppSystem;

    iput-object p2, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$databaseHelper:Lcom/melesta/engine/DatabaseHelper;

    iput-object p3, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$mItemName:Ljava/lang/String;

    iput-object p4, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$mSku:Ljava/lang/String;

    iput p5, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$mCountPerItem:I

    iput-object p6, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$tr:Lcom/melesta/payment/PaymentTransaction;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method


# virtual methods
.method public onIabPurchaseFinished(Lcom/melesta/payment/inapp3/IabResult;Lcom/melesta/payment/inapp3/Purchase;)V
    .locals 10
    .parameter "result"
    .parameter "purchase"

    .prologue
    .line 250
    invoke-static {}, Lcom/melesta/payment/PaymentManager;->getInstance()Lcom/melesta/payment/PaymentManager;

    move-result-object v2

    .line 252
    .local v2, pm:Lcom/melesta/payment/PaymentManager;
    const-string v5, "payment-inapp"

    new-instance v6, Ljava/lang/StringBuilder;

    invoke-direct {v6}, Ljava/lang/StringBuilder;-><init>()V

    const-string v7, "Purchase finished: "

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v6

    const-string v7, ", purchase: "

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-static {v5, v6}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 254
    iget-object v5, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$databaseHelper:Lcom/melesta/engine/DatabaseHelper;

    invoke-virtual {v5}, Lcom/melesta/engine/DatabaseHelper;->getTransactions()Ljava/util/List;

    move-result-object v5

    invoke-static {v5}, Lcom/melesta/payment/PaymentTransaction;->dump(Ljava/util/List;)V

    .line 256
    new-instance v5, Lcom/melesta/payment/inapp3/InAppResponse;

    invoke-direct {v5}, Lcom/melesta/payment/inapp3/InAppResponse;-><init>()V

    iget-object v6, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$mItemName:Ljava/lang/String;

    invoke-virtual {v5, v6}, Lcom/melesta/payment/inapp3/InAppResponse;->setName(Ljava/lang/String;)Lcom/melesta/payment/inapp3/InAppResponse;

    move-result-object v5

    iget-object v6, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$mSku:Ljava/lang/String;

    invoke-virtual {v5, v6}, Lcom/melesta/payment/inapp3/InAppResponse;->setSku(Ljava/lang/String;)Lcom/melesta/payment/inapp3/InAppResponse;

    move-result-object v5

    iget v6, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$mCountPerItem:I

    invoke-virtual {v5, v6}, Lcom/melesta/payment/inapp3/InAppResponse;->setCountPerItem(I)Lcom/melesta/payment/inapp3/InAppResponse;

    move-result-object v5

    iget-object v6, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->this$0:Lcom/melesta/payment/inapp3/InAppSystem;

    #getter for: Lcom/melesta/payment/inapp3/InAppSystem;->defaultListener:Lcom/melesta/payment/interfaces/IListener;
    invoke-static {v6}, Lcom/melesta/payment/inapp3/InAppSystem;->access$000(Lcom/melesta/payment/inapp3/InAppSystem;)Lcom/melesta/payment/interfaces/IListener;

    move-result-object v6

    invoke-virtual {v5, v6}, Lcom/melesta/payment/inapp3/InAppResponse;->setListener(Lcom/melesta/payment/interfaces/IListener;)Lcom/melesta/payment/inapp3/InAppResponse;

    move-result-object v4

    .line 262
    .local v4, response:Lcom/melesta/payment/inapp3/InAppResponse;
    new-instance v5, Lcom/melesta/payment/inapp3/InAppRequestFilter;

    invoke-direct {v5}, Lcom/melesta/payment/inapp3/InAppRequestFilter;-><init>()V

    iget-object v6, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$mSku:Ljava/lang/String;

    invoke-virtual {v5, v6}, Lcom/melesta/payment/inapp3/InAppRequestFilter;->setSku(Ljava/lang/String;)Lcom/melesta/payment/inapp3/InAppRequestFilter;

    move-result-object v5

    invoke-virtual {v2, v5}, Lcom/melesta/payment/PaymentManager;->getActiveRequest(Lcom/melesta/payment/interfaces/IRequestFilter;)Lcom/melesta/payment/interfaces/IRequest;

    move-result-object v3

    check-cast v3, Lcom/melesta/payment/inapp3/InAppRequest;

    .line 263
    .local v3, request:Lcom/melesta/payment/inapp3/InAppRequest;
    if-nez v3, :cond_0

    .line 294
    :goto_0
    return-void

    .line 266
    :cond_0
    invoke-virtual {p1}, Lcom/melesta/payment/inapp3/IabResult;->isFailure()Z

    move-result v5

    if-eqz v5, :cond_1

    .line 267
    iget-object v5, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$databaseHelper:Lcom/melesta/engine/DatabaseHelper;

    iget-object v6, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$tr:Lcom/melesta/payment/PaymentTransaction;

    iget-wide v6, v6, Lcom/melesta/payment/PaymentTransaction;->internalId:J

    invoke-virtual {v5, v6, v7}, Lcom/melesta/engine/DatabaseHelper;->deleteTransaction(J)Z

    .line 268
    const-string v5, "payment-inapp"

    const-string v6, "Purchase failed."

    invoke-static {v5, v6}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 269
    sget-object v5, Lcom/melesta/payment/inapp3/InAppResponse$Status;->ERROR:Lcom/melesta/payment/inapp3/InAppResponse$Status;

    invoke-virtual {v4, v5}, Lcom/melesta/payment/inapp3/InAppResponse;->setStatus(Lcom/melesta/payment/inapp3/InAppResponse$Status;)Lcom/melesta/payment/inapp3/InAppResponse;

    move-result-object v5

    sget-object v6, Lcom/google/Consts$ResponseCode;->RESULT_ERROR:Lcom/google/Consts$ResponseCode;

    invoke-virtual {v6}, Lcom/google/Consts$ResponseCode;->ordinal()I

    move-result v6

    invoke-virtual {v5, v6}, Lcom/melesta/payment/inapp3/InAppResponse;->setErrorCode(I)Lcom/melesta/payment/inapp3/InAppResponse;

    .line 292
    :goto_1
    invoke-virtual {v2, v4}, Lcom/melesta/payment/PaymentManager;->postResponse(Lcom/melesta/payment/interfaces/IResponse;)V

    .line 293
    invoke-virtual {v2, v3}, Lcom/melesta/payment/PaymentManager;->removeActiveRequest(Lcom/melesta/payment/interfaces/IRequest;)V

    goto :goto_0

    .line 272
    :cond_1
    invoke-virtual {p1}, Lcom/melesta/payment/inapp3/IabResult;->isCanceled()Z

    move-result v5

    if-eqz v5, :cond_2

    .line 273
    iget-object v5, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$databaseHelper:Lcom/melesta/engine/DatabaseHelper;

    iget-object v6, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$tr:Lcom/melesta/payment/PaymentTransaction;

    iget-wide v6, v6, Lcom/melesta/payment/PaymentTransaction;->internalId:J

    invoke-virtual {v5, v6, v7}, Lcom/melesta/engine/DatabaseHelper;->deleteTransaction(J)Z

    .line 274
    const-string v5, "payment-inapp"

    const-string v6, "Purchase failed."

    invoke-static {v5, v6}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 275
    sget-object v5, Lcom/melesta/payment/inapp3/InAppResponse$Status;->CANCEL:Lcom/melesta/payment/inapp3/InAppResponse$Status;

    invoke-virtual {v4, v5}, Lcom/melesta/payment/inapp3/InAppResponse;->setStatus(Lcom/melesta/payment/inapp3/InAppResponse$Status;)Lcom/melesta/payment/inapp3/InAppResponse;

    move-result-object v5

    sget-object v6, Lcom/google/Consts$ResponseCode;->RESULT_USER_CANCELED:Lcom/google/Consts$ResponseCode;

    invoke-virtual {v6}, Lcom/google/Consts$ResponseCode;->ordinal()I

    move-result v6

    invoke-virtual {v5, v6}, Lcom/melesta/payment/inapp3/InAppResponse;->setErrorCode(I)Lcom/melesta/payment/inapp3/InAppResponse;

    goto :goto_1

    .line 280
    :cond_2
    iget-object v5, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$tr:Lcom/melesta/payment/PaymentTransaction;

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v6

    iput-wide v6, v5, Lcom/melesta/payment/PaymentTransaction;->time:J

    .line 281
    iget-object v5, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$tr:Lcom/melesta/payment/PaymentTransaction;

    iget-object v6, p2, Lcom/melesta/payment/inapp3/Purchase;->mOriginalJson:Ljava/lang/String;

    iput-object v6, v5, Lcom/melesta/payment/PaymentTransaction;->customData:Ljava/lang/String;

    .line 283
    iget-object v5, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$databaseHelper:Lcom/melesta/engine/DatabaseHelper;

    iget-object v6, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$tr:Lcom/melesta/payment/PaymentTransaction;

    invoke-virtual {v5, v6}, Lcom/melesta/engine/DatabaseHelper;->saveTransaction(Lcom/melesta/payment/PaymentTransaction;)J

    move-result-wide v0

    .line 285
    .local v0, id:J
    sget-object v5, Lcom/melesta/payment/inapp3/InAppResponse$Status;->PURCHASED:Lcom/melesta/payment/inapp3/InAppResponse$Status;

    invoke-virtual {v4, v5}, Lcom/melesta/payment/inapp3/InAppResponse;->setStatus(Lcom/melesta/payment/inapp3/InAppResponse$Status;)Lcom/melesta/payment/inapp3/InAppResponse;

    move-result-object v5

    invoke-virtual {v5, v0, v1}, Lcom/melesta/payment/inapp3/InAppResponse;->setInternalId(J)V

    .line 288
    iget-object v5, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->this$0:Lcom/melesta/payment/inapp3/InAppSystem;

    iget-object v5, v5, Lcom/melesta/payment/inapp3/InAppSystem;->mHelper:Lcom/melesta/payment/inapp3/IabHelper;

    new-instance v6, Lcom/melesta/payment/inapp3/InAppSystem$ConsumeFinishedListener;

    iget-object v7, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->this$0:Lcom/melesta/payment/inapp3/InAppSystem;

    iget-object v8, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$tr:Lcom/melesta/payment/PaymentTransaction;

    iget-object v9, p0, Lcom/melesta/payment/inapp3/InAppSystem$3;->val$databaseHelper:Lcom/melesta/engine/DatabaseHelper;

    invoke-direct {v6, v7, v8, v9}, Lcom/melesta/payment/inapp3/InAppSystem$ConsumeFinishedListener;-><init>(Lcom/melesta/payment/inapp3/InAppSystem;Lcom/melesta/payment/PaymentTransaction;Lcom/melesta/engine/DatabaseHelper;)V

    invoke-virtual {v5, p2, v6}, Lcom/melesta/payment/inapp3/IabHelper;->consumeAsync(Lcom/melesta/payment/inapp3/Purchase;Lcom/melesta/payment/inapp3/IabHelper$OnConsumeFinishedListener;)V

    .line 290
    const-string v5, "payment-inapp"

    const-string v6, "Purchase successful."

    invoke-static {v5, v6}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_1
.end method
